/**
 * Created by ROCK on 2018/1/8.
 */
(function () {
    'use strict';

    angular
        .module('news.detail.controller', [])
        .controller('NewsDetailCtrl',NewsDetailCtrl);

    NewsDetailCtrl.$inject = ['$scope','$yikeUtils','$state','$ionicHistory','$ionicModal','$ionicTabsDelegate','localStorageService','$sce'];
    /* @ngInject */
    function NewsDetailCtrl($scope,$yikeUtils,$state,$ionicHistory,$ionicModal,$ionicTabsDelegate,localStorageService,$sce) {
        $scope.user = localStorageService.get('user');
        $scope.id = $state.params.id;
        init();
        function init() {
            yikeTaishan.newsDetail($scope.id,$scope.user.token)
                .then(function (data) {
                    console.log(data);


                    var pattern1=/&lt;/gim;
                    var pattern2=/&gt;/gim;
                    var pattern3=/&quot;/gim;

                    data.result.update.content = data.result.update.content.replace(pattern1,'<');
                    data.result.update.content = data.result.update.content.replace(pattern2,'>');
                    data.result.update.content = data.result.update.content.replace(pattern3,'"');
                    data.result.update.content = $sce.trustAsHtml(data.result.update.content);


                    $scope.article = data.result.update;
                    console.log($scope.article);


                    $scope.informationList = data.result.recommend;
                    //console.log($scope.article);
                    //console.log($scope.informationList);
                    $scope.$digest();
                });
        }
    }
})();
